package edu.sysu.cshare.dao;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import edu.sysu.cshare.util.HibernateSessionFactory;
import edu.sysu.cshare.util.Mis;

@Entity
@Table(name = "T_SUBMITINFO")
public class SubmitInfo implements Serializable {
	private Homework homework;
	private long id;
	private String savePath;
	private Calendar submitDate;
	/**
	 * 作业信息的持有者
	 */
	private User user;

	public SubmitInfo() {

	}

	@Override
	public String toString() {
		return "SubmitInfo [homework=" + homework.getId() + ", id=" + id
				+ ", savePath=" + savePath + ", submitDate=" + submitDate
				+ ", user=" + user + "]";
	}

	public static SubmitInfo getSubmitInfoById(long id) {
		return (SubmitInfo) HibernateSessionFactory.getSession().load(
				SubmitInfo.class, id);
	}


	

	public SubmitInfo(Homework homework, Calendar submitDate, User user) {
		super();
		this.homework = homework;
		this.submitDate = submitDate;
		this.user = user;
	}

	@ManyToOne
	public Homework getHomework() {
		return homework;
	}

	@Id
	@GeneratedValue
	public long getId() {
		return id;
	}

	public String getSavePath() {
		return savePath;
	}

	public Calendar getSubmitDate() {
		return submitDate;
	}

	@ManyToOne
	public User getUser() {
		return user;
	}

	public void setHomework(Homework homework) {
		this.homework = homework;
	}

	public void setId(long id) {
		this.id = id;
	}

	public void setSavePath(String savePath) {
		this.savePath = savePath;
	}

	public void setSubmitDate(Calendar submitDate) {
		this.submitDate = submitDate;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
